import utils from '@/utils'
import { StaffQrcode, GroupQrcode, QrcodeTypeEnum } from './interface'

// 员工活码示例数据
export const mockStaffQrcodes: StaffQrcode[] = [
  {
    id: 1,
    name: '销售部新客户添加',
    createTime: '2024-01-15 10:00:00',
    creator: '张三',
    qrcodeImg: 'https://example.com/qrcode1.jpg',
    todayScanCount: 25,
    totalScanCount: 1250,
    type: QrcodeTypeEnum.CREATE_AND_USE,
    users: [
      {
        userId: 'user1',
        userName: '李四'
      },
      {
        userId: 'user2',
        userName: '王五'
      }
    ],
    creatorWorkTime: {
      start: '09:00',
      end: '18:00'
    },
    userWorkTime: [
      {
        userId: 'user1',
        start: '09:00',
        end: '18:00'
      },
      {
        userId: 'user2',
        start: '10:00',
        end: '19:00'
      }
    ]
  },
  {
    id: 2,
    name: '客服部客户服务',
    createTime: '2024-01-16 14:30:00',
    creator: '李四',
    qrcodeImg: 'https://example.com/qrcode2.jpg',
    todayScanCount: 15,
    totalScanCount: 850,
    type: QrcodeTypeEnum.PROMOTE,
    users: [
      {
        userId: 'user3',
        userName: '赵六'
      }
    ],
    creatorWorkTime: {
      start: '08:00',
      end: '17:00'
    },
    userWorkTime: [
      {
        userId: 'user3',
        start: '08:00',
        end: '17:00'
      }
    ]
  }
]

// 群活码示例数据
export const mockGroupQrcodes: GroupQrcode[] = [
  {
    id: 101,
    name: '产品交流群',
    createTime: '2024-01-15 09:00:00',
    creator: '张三',
    qrcodeImg: 'https://example.com/group1.jpg',
    todayScanCount: 30,
    totalScanCount: 1500
  },
  {
    id: 102,
    name: '售后服务群',
    createTime: '2024-01-16 11:00:00',
    creator: '李四',
    qrcodeImg: 'https://example.com/group2.jpg',
    todayScanCount: 20,
    totalScanCount: 1200
  }
]

// 模拟获取列表数据的函数
export const mockGetQrcodeList = (params: any) => {
  return new Promise((resolve) => {
    utils.$loading(true)
    setTimeout(() => {
      const { tab, page, pageSize } = params
      const list = tab === 1 ? mockStaffQrcodes : mockGroupQrcodes
      const startIndex = (page - 1) * pageSize
      const endIndex = startIndex + pageSize
      utils.$loading(false)
      resolve({
        data: {
          list: list.slice(startIndex, endIndex),
          total: list.length
        },
      })
    }, 1000)
  })
}
